package zhihuilan.controlle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import zhihuilan.common.Response;
import zhihuilan.common.enums.ResultEnum;
import zhihuilan.entity.MyStaff;
import zhihuilan.entity.MyUser;
import zhihuilan.params.query.MyStaffQueryParam;
import zhihuilan.service.MyUserService;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/sysUser")
public class UserControlle extends BasicController {
    @Resource
    private MyUserService myUserService;

    @GetMapping("/getList")
    public Response getList() {

        List<MyUser> list = myUserService.selectUserList(0, 0, "");
        return Response.ok(list);
    }

    @GetMapping("/selectById")
    public Response selectById(@RequestBody MyStaffQueryParam queryParam) {
        // 验证用户登陆行为
        if(!this.isCheckLogin(queryParam.getGuid())){
            //如果用户未登陆，提示用户未登陆信息，并且返回未登陆的枚举编码；
            return Response.error(ResultEnum.UNLOGIN.getKey(),ResultEnum.UNLOGIN.getValue());
        }
        MyStaff user = currentStaff;
        return Response.ok(user);
    }
}
